package com.chinasofti.java8.demo;

import org.junit.Test;

public class TestLambda {
    @Test
    public void test1() {
        Integer num = opreation(100, (x) -> x * x);
        System.out.println("num=" + num);
        Integer num1 = opreation(100, (y) -> y + 200);
        System.out.println("num1=" + num1);
    }
    public Integer opreation(Integer num, MyFun mf) {
        return mf.getValue(num);

    }
    @Test
    public void test2() {
        String str = opreation1("abc", (x) -> x.toUpperCase());
        String str1 = opreation1("abcd", (x) -> x.substring(1, 3));
    }
    public String opreation1(String str, MyFun1 mf) {
        String s = mf.getValue(str);
        System.out.println(s);
        return s;
    }
    @Test
    public void test3() {
        op(100L, 200L, (x, y) -> Math.toIntExact(x + y));
        op(100L, 200L, (x, y) -> Math.toIntExact(x * y));
    }
    public void op(Long l1, Long l2, MyFun2<Long, Long> mf) {
        System.out.println(mf.getValue(l1, l2));
    }

}
